package org.zsl.controller;


import com.alibaba.fastjson.JSON;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.zsl.mapper.UserMapper;
import org.zsl.model.ResponseMessage;
import org.zsl.model.User;
import org.zsl.service.UserService;

/**
 *  controller 对应业务页面
 * */
@RestController
@RequestMapping("/user")
@CrossOrigin
public class UserController {


    @Autowired
    private UserService service;


    /**
     * 测试工具 --  postman apifox
     * 前后台联调
     */
    @PostMapping("/login")
    public String login(User user) {
        return JSON.toJSONString(service.login(user));
    }


    @PostMapping("/password/change")
    public String changePassword(String password,Integer userId){

        User user = new User();
        user.setUserId(userId);
        user.setPassword(password);

      return JSON.toJSONString(service.changePassword(user))  ;
    }

    @PostMapping("/updateInfo")
    public String updateInfo(User user){

     return JSON.toJSONString(service.updateInfo(user))  ;
    }


    /**
     *  未完成功能:
     *     添加用户
     *     删除用户
     * */

}